package srkpreference.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.jface.dialogs.MessageDialog;

import srkpreference.Activator;
import srkpreference.preferences.PreferenceConstants;

/**
 * Our sample handler extends AbstractHandler, an IHandler base class.
 * 
 * @see org.eclipse.core.commands.IHandler
 * @see org.eclipse.core.commands.AbstractHandler
 */
public class SrkSampleHandler extends AbstractHandler {
	/**
	 * The constructor.
	 */
	public SrkSampleHandler() {
	}

	/**
	 * the command has been executed, so extract extract the needed information
	 * from the application context.
	 */
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IWorkbenchWindow window = HandlerUtil
				.getActiveWorkbenchWindowChecked(event);
		/*
		 * MessageDialog.openInformation( window.getShell(), "SrkPreference",
		 * "Hello, Eclipse world");
		 */
		System.out.println("Srk ");
		IEditorSite editorSite = PlatformUI.getWorkbench()
				.getActiveWorkbenchWindow().getActivePage().getActiveEditor()
				.getEditorSite();
		System.out.println(editorSite.toString());

		String string = Activator.getDefault().getPreferenceStore()
				.getString(PreferenceConstants.P_STRING);
		System.out.println(string);
		return null;
	}
}
